$(function(){
    scroll(function(direction) { console.log(direction) });  
    
	function stopPropagation(e) {
		if (e.stopPropagation)
		e.stopPropagation();
		else
		e.cancelBubble = true;
	}

		$(document).bind('click',function(){
            $(".h_ul").find("ul").addClass("hide");
            $(".h_ul li").removeClass("on");
		});

		/*$('#test').bind('click',function(e){
		stopPropagation(e);
		}); */
	
	
	
	
	$(".h_ul li").click(function () {
        $(this).addClass("on").siblings().removeClass("on");
    });

    $(".h_li2,.h_li3").bind('click',function (e) {
		stopPropagation(e);
        if ($(this).find("ul").hasClass("hide") == true) {
            $(".h_ul").find("ul").addClass("hide");
            $(this).find("ul").removeClass("hide");
        } else{
            $(this).find("ul").addClass("hide");
        }

    	$(".cate_big").find("ul").addClass("hide");
    	$(".cate_big li").removeClass("on");
    });
    
    
    
    function scroll( fn ) {  
        var beforeScrollTop = document.body.scrollTop,  
            fn = fn || function() {};  
        window.addEventListener("scroll", function() {  
            var afterScrollTop = document.body.scrollTop,  
                delta = afterScrollTop - beforeScrollTop;  
            if( delta === 0 ){ return false}else{


                    $(".h_ul").find("ul").addClass("hide");
                    $(".h_ul li").removeClass("on");
            };  
            //fn( delta > 0 ? "down" : "up" );  
            //beforeScrollTop = afterScrollTop;  
        }, false);  
    } 
	
});

    


